<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//
//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});

//没有登录
Route::group(["namespace" => 'Api'], function () {
    //用户相关
    Route::group(["prefix" => 'user'], function ($router) {
        $router->post('register', 'UserController@register');//账号密码注册
        $router->post('login_pass', 'UserController@loginPass');//密码登录

    });
});

//不要求强制登录
Route::group(["namespace" => 'Api', 'middleware' => ['user']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
    });
    Route::group(["prefix" => 'platform'], function ($router) {
    });
});

//要求登录
Route::group(["namespace" => 'Api', 'middleware' => ['user.auth']], function () {
    Route::group(["prefix" => 'user'], function ($router) {
        $router->get('main', 'UserCenterController@main');
        $router->get('current', 'UserCenterController@userCurrentTeam');//用户当前默认加载的队伍
        $router->post('save', 'UserCenterController@updateUserInfo');
        $router->post('logout', 'UserController@logout')->name('user-logout');
    });

    //项目
    Route::group(["prefix" => 'project'], function ($router) {
        $router->get('soft-lists', 'ProjectController@softLists');//轻列表，只有名称
        $router->get('soft-detail', 'ProjectController@softDetail');//轻详情，不带成员
        $router->get('lists', 'ProjectController@lists');//调研中心
        $router->get('search', 'ProjectController@searchLists');//项目搜索
        $router->get('sweep', 'ProjectController@sweepList');//项目扫街列表
    });
    //任务：扫街和入户
    Route::group(["prefix" => 'task'], function ($router) {
        $router->post('sweep-add', 'TaskController@sweepAdd');//扫街任务（标记）添加/编辑
        $router->get('sweep-lists', 'TaskController@lists');//调研详情
        $router->get('entry-survey-get', 'TaskController@entrySurveyGet');//入户调研获取
        $router->post('entry-survey-save', 'TaskController@entrySurveySave');//入户调研保存
        $router->get('sign', 'TaskController@teamSign');//队伍标记
        $router->get('sign_detail', 'TaskController@signDetail');//标记详情
        $router->post('sweep-delete', 'TaskController@sweepDelete');//删除扫街
        $router->get('pos', 'TaskController@teamPos');//队伍队员位置
    });
    //队伍
    Route::group(["prefix" => 'team'], function ($router) {
        $router->get('lists', 'TeamController@lists');//队伍列表
        $router->get('info', 'TeamController@teamInfo');//队伍信息
        $router->get('user-lists', 'TeamController@userlists');//队伍成员列表
        $router->post('create', 'TeamController@createTeam');//创建队伍
        $router->post('entrance', 'TeamController@entranceTeam');//加入队伍
        $router->post('update', 'TeamController@updateTeam');//队伍设置（置顶，设置加载，解散）
        $router->post('remove', 'TeamController@removeMember');//移除成员
        $router->post('set_pos', 'TeamController@updateUserPos');//更新队员在队伍位置
    });


    Route::group(["prefix" => 'upload'], function ($router) {
        $router->post('upload', 'uploadController@upload');
    });

});

